package com.dream.myqiyi.db;

import java.sql.SQLException;

import com.dream.myqiyi.dao.NoteModel;
import com.dream.myqiyi.dao.NotebookModel;
import com.j256.ormlite.dao.BaseDaoImpl;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.dao.DaoManager;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;

public class NotebookDaoImpl extends BaseDaoImpl<NotebookModel, String> implements NotebookDao {
	Dao<NotebookModel, String> notebookDao;
	
	public NotebookDaoImpl(ConnectionSource connectionSource) throws SQLException {
		super(connectionSource, NotebookModel.class);
	}
	
	public void performDBOperations(ConnectionSource connectionSource) throws SQLException {
		notebookDao = DaoManager.createDao(connectionSource, NotebookModel.class);
		
		// create table
		TableUtils.createTableIfNotExists(connectionSource, NotebookModel.class);
	}
	
	public Dao<NotebookModel, String> getDao() {
		return notebookDao;
	}

}
